package com.wanmait.employment.manageController;

import com.wanmait.employment.entity.FinancingStage;
import com.wanmait.employment.mapper.FinancingStageMapper;
import com.wanmait.employment.service.FinancingStageService;
import com.wanmait.employment.util.AjaxResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/manage/FinancingStage/")
public class FinancingStageController {
    @Resource
    private FinancingStageService financingStageService;

    @GetMapping("list")
    public AjaxResult List(String title){
        List<FinancingStage> financingStages=financingStageService.selectList(title);
        return AjaxResult.success("",financingStages);
    }
//    @PostMapping("insert")
//    public AjaxResult insert(@RequestBody  FinancingStage financingStage){
//        Integer integer=financingStageService.insert(financingStage);
//        return AjaxResult.success("添加成功");
//    }
    @PostMapping("update")
    public AjaxResult update(@RequestBody FinancingStage financingStage) {
        if (financingStage.getId() != null) {
            financingStageService.update(financingStage);
            return AjaxResult.success("");
        } else {
            financingStageService.insert(financingStage);
            return AjaxResult.success("");
        }
    }



    @GetMapping ("delete")
    public AjaxResult delete(Integer id){
        financingStageService.delete(id);
        return  AjaxResult.success("删除成功");
    }
}
